package com.spa.application.command.admin;

import com.spa.application.command.common.rule.RuleAddCommand;
import com.spa.infrastructure.util.UrlUtil;
import lombok.Data;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.List;

@Data
public class ShopAddCommand {

    @NotBlank(message = "门店名称不能为空")
    private String name;

    @NotBlank(message = "负责人不能为空")
    private String owner;

    @NotBlank(message = "负责人电话不能为空")
    @Size(min = 11, max = 11, message = "手机号只能为11位")
    @Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误")
    private String phone;

    @NotBlank(message = "门店地址不能为空")
    private String address;

    @NotNull(message = "开通城市不能为空")
    private Long cityId;

    @NotBlank(message = "登录账号不能为空")
    @Size(min = 11, max = 11, message = "手机号只能为11位")
//    @Pattern(regexp = "^[1][3,4,5,6,7,8,9][0-9]{9}$", message = "手机号格式有误")
    private String account;

    @NotBlank(message = "门店logo不能为空")
    private String logo;

    @NotBlank(message = "营业执照不能为空")
    private String businessLicense;

    @NotBlank(message = "商家介绍不能为空")
    private String remark;

    private Integer withdrawPeriod;

    @NotNull(message = "规则必填")
    private List<RuleAddCommand> ruleDtoList;

    public void setLogo(String logo) {
        this.logo = UrlUtil.handleUrl(logo,",");
    }

    public void setBusinessLicense(String businessLicense) {
        this.businessLicense = UrlUtil.handleUrl(businessLicense,",");
    }

}
